package demo.Listener;

import com.alibaba.fastjson.JSONObject;
import demo.config.RabbitConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @program: ReceiveHandler
 * @author: 张磊
 * @create: 2019/5/27-12:42
 **/
@Component
public class ReceiveHandler {

    //监听email队列
    @RabbitListener(queues = {RabbitConfig.QUEUE_INFORM_EMAIL})
    public void receive_email(String msg, Message message){
        System.out.println("msg: "+msg);
        String s=JSONObject.toJSONString(message);
        System.out.println(s);
    }


    //监听SMS队列
    @RabbitListener(queues = {RabbitConfig.QUEUE_INFORM_SMS})
    public void receive_SMS(String msg,Message message){
        System.out.println("msg: "+msg);
        String s=JSONObject.toJSONString(message);
        System.out.println(s);
    }
}
